﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HelpCentral.Core.Services;
using HelpCentral.Service.Shared;
using HelpCentral.Core.Objects;

namespace HelpCentral.Service.Clients
{
    class ClientService : IClientService
    {
        public ClientResponse VerifyLicense(Guid license)
        {
            var cs = new HelpCentral.Core.Services.ClientService();
            var c = cs.GetClientByLicense(license);
            var sr = new ClientResponse();

            sr.Result = false;
            sr.Message = "License verification failed.";
            sr.VerifiedClient = null;

            if (c != null)
            {
                if (c.ActivateDate <= DateTime.Now && (c.DeactivateDate == null || c.DeactivateDate >= DateTime.Now))
                {
                    sr.Result = true;
                    sr.Message = "License verification succeeded.";
                    sr.VerifiedClient = c;
                }
            }

            return sr;
        }
    }
}
